#! /bin/bash
del_default_spinruntime() {
    kubectl delete runtimeclasses.node.k8s.io spin
}
get_spin_tag() {
    spin_tag=$(curl -sL https://api.github.com/repos/spinframework/spin-operator/tags | jq -r '.[0].name')
    echo "spin_tag: ${spin_tag}"
    # # CRD
    kubectl apply -f https://github.com/spinframework/spin-operator/releases/download/${spin_tag}/spin-operator.crds.yaml

    # # 运行时
    kubectl apply -f https://github.com/spinframework/spin-operator/releases/download/${spin_tag}/spin-operator.runtime-class.yaml

    # # shim-executor
    kubectl apply -f https://github.com/spinframework/spin-operator/releases/download/${spin_tag}/spin-operator.shim-executor.yaml

}
del_default_spinruntime
get_spin_tag
